package cn.gson.springboot.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.Objects;

@Entity
@Table(name = "solution_", schema = "crm")
public class Solution {
    private int solutionId;
    private String solutionTheme;
    private Date solutionDate;
    private String solutionFeedback;
    private String solutionContent;
    private Opportunity opportunityByOppId;
    private Customer customerByCustomerId;

    @Id
    @Column(name = "solution_id", nullable = false)
    public int getSolutionId() {
        return solutionId;
    }

    public void setSolutionId(int solutionId) {
        this.solutionId = solutionId;
    }


    @Basic
    @Column(name = "solution_theme", nullable = true, length = 255)
    public String getSolutionTheme() {
        return solutionTheme;
    }

    public void setSolutionTheme(String solutionTheme) {
        this.solutionTheme = solutionTheme;
    }

    @Basic
    @Column(name = "solution_date", nullable = true)
    public Date getSolutionDate() {
        return solutionDate;
    }

    public void setSolutionDate(Date solutionDate) {
        this.solutionDate = solutionDate;
    }

    @Basic
    @Column(name = "solution_feedback", nullable = true, length = 255)
    public String getSolutionFeedback() {
        return solutionFeedback;
    }

    public void setSolutionFeedback(String solutionFeedback) {
        this.solutionFeedback = solutionFeedback;
    }

    @Basic
    @Column(name = "solution_content", nullable = true, length = 255)
    public String getSolutionContent() {
        return solutionContent;
    }

    public void setSolutionContent(String solutionContent) {
        this.solutionContent = solutionContent;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Solution solution = (Solution) o;
        return solutionId == solution.solutionId &&
                Objects.equals(solutionTheme, solution.solutionTheme) &&
                Objects.equals(solutionDate, solution.solutionDate) &&
                Objects.equals(solutionFeedback, solution.solutionFeedback) &&
                Objects.equals(solutionContent, solution.solutionContent);
    }

    @Override
    public int hashCode() {
        return Objects.hash(solutionId, solutionTheme, solutionDate, solutionFeedback, solutionContent);
    }

    @ManyToOne
    @JoinColumn(name = "opp_id", referencedColumnName = "opp_id")
    public Opportunity getOpportunityByOppId() {
        return opportunityByOppId;
    }

    public void setOpportunityByOppId(Opportunity opportunityByOppId) {
        this.opportunityByOppId = opportunityByOppId;
    }

    @ManyToOne
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id")
    public Customer getCustomerByCustomerId() {
        return customerByCustomerId;
    }

    public void setCustomerByCustomerId(Customer customerByCustomerId) {
        this.customerByCustomerId = customerByCustomerId;
    }
}
